package com.leinao.open;

import com.leinao.constant.Constant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.leinao.commons.Response;
import com.leinao.dataset.service.DataSetService;
import com.leinao.util.page.PageInfo;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * @author  wangshoufa 
 * @date 2019年1月22日 下午3:38:50
 *
 */

@RestController
@CrossOrigin
public class DataSetInfoController {
	
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	private DataSetService dataSetService;
	
	
	@ApiOperation(value="获取公开数据集信息", notes="返回公开数据集")
	@GetMapping(value = "/openDataSetInfo")
	public Response<PageInfo> openDataSetInfo(@ApiParam(value = "当前页") @RequestParam(required = false) Integer cp,
												   @ApiParam(value = "每页条数") @RequestParam(required = false) Integer ps) {
		logger.info("openDataSetInfo param: cp is {}, ps is {}", cp, ps);
		cp = null == cp ? Constant.DEFAULT_PAGE_NUMBER : cp;
		ps = null == ps ? Constant.DEFAULT_PAGE_SIZE : ps;

		return dataSetService.queryOpenDataSetInfo(cp, ps);
	}
}
